package org.ourgrid.worker.communication.sender;

import org.ourgrid.common.interfaces.WorkerSpecListener;
import org.ourgrid.common.internal.SenderIF;
import org.ourgrid.worker.business.dao.WorkerDAOFactory;
import org.ourgrid.worker.response.SetWorkerSpecListenerResponseTO;

import br.edu.ufcg.lsd.commune.container.servicemanager.ServiceManager;
import br.edu.ufcg.lsd.commune.identification.DeploymentID;
import br.edu.ufcg.lsd.commune.identification.ServiceID;

public class SetWorkerSpecListenerSender implements SenderIF<SetWorkerSpecListenerResponseTO> {

	public void execute(SetWorkerSpecListenerResponseTO response, ServiceManager manager) {
		ServiceID serviceID = (new DeploymentID(response.getClientAddress())).getServiceID();
		
		WorkerSpecListener workerSpecListener = (WorkerSpecListener) manager.getStub(serviceID, WorkerSpecListener.class);
		
		WorkerDAOFactory.getInstance().getWorkerSpecListenerDAO().setPeerWorkerSpecListener(workerSpecListener);
	}
}
